-- Calculate the nth Fibonacci number
function fib(n)
    if n <= 2 then
        return 1
    end
    local a = 1
    local b = 1
    for i = 3, n do
        local temp = b
        b = b + a
        a = temp
    end
    return b
end

local start_time = os.clock()

local num = 0
local result

-- Call the fib function
for i = 1, 500 do
    result = fib(i)
    num = i -- Just to keep the same variable name as in the original code
end

-- Record end time and output results
local end_time = os.clock()
local cpu_time_used = end_time - start_time
print("num = " .. num)

print("Lua time: " .. cpu_time_used .. " seconds")
print("Fibonacci number is: " .. result)